var e,
  t = s(require("../../../../@babel/runtime/regenerator")),
  r = require("../../../../@babel/runtime/helpers/asyncToGenerator"),
  n = s(require("@/config/index")),
  i = require("@/services/base/user"),
  a = require("@/services/user-service"),
  o = require("@/utils/jump"),
  u = s(require("@/config/page"));
function s(e) {
  return e && e.__esModule ? e : { default: e };
}
Component({
  properties: { userInfo: { type: Object, default: {} } },
  data: {
    swiperCurrent: 3,
    isCheck: !1,
    isRegister: !(
      null === (e = (0, a.getLoginInfo)()) ||
      void 0 === e ||
      !e.uid
    ),
    pic: "".concat(n.default.CDN, "/account/avatar3.png"),
  },
  attached: function () {
    var e;
    this.setData({
      isRegister: !(
        null === (e = (0, a.getLoginInfo)()) ||
        void 0 === e ||
        !e.uid
      ),
    });
  },
  methods: {
    onCheck: function () {
      this.setData({ isCheck: !this.data.isCheck });
    },
    getPhoneNumber: function (e) {
      var o = this;
      return r(
        t.default.mark(function r() {
          var u, s;
          return t.default.wrap(function (t) {
            for (;;)
              switch ((t.prev = t.next)) {
                case 0:
                  if ("getPhoneNumber:ok" !== e.detail.errMsg) {
                    t.next = 10;
                    break;
                  }
                  return (
                    (u = e.detail.code),
                    (t.next = 4),
                    (0, i.postMobile)({ appId: n.default.appId, code: u })
                  );
                case 4:
                  return (
                    (s = t.sent),
                    console.log("授权手机号登录", s),
                    (t.next = 8),
                    (0, a.getUserId)(!0)
                  );
                case 8:
                  return (t.next = 10), o.onLogin();
                case 10:
                case "end":
                  return t.stop();
              }
          }, r);
        }),
      )();
    },
    onLogin: function () {
      var e = this;
      return r(
        t.default.mark(function r() {
          var n;
          return t.default.wrap(function (t) {
            for (;;)
              switch ((t.prev = t.next)) {
                case 0:
                  if (e.data.isCheck) {
                    t.next = 3;
                    break;
                  }
                  return (
                    wx.showToast({
                      title: "请先勾选确认",
                      icon: "none",
                      duration: 2500,
                    }),
                    t.abrupt("return")
                  );
                case 3:
                  return (t.next = 5), (0, a.login)(e.data.pic);
                case 5:
                  t.sent
                    ? ((n = (0, a.getUserInfo)()),
                      e.triggerEvent("loginFunc", n))
                    : wx.showToast({
                        title: "登录失败",
                        icon: "none",
                        duration: 2500,
                      });
                case 7:
                case "end":
                  return t.stop();
              }
          }, r);
        }),
      )();
    },
    onChangeSwiper: function (e) {
      var t = e.detail;
      this.setData({
        swiperCurrent: null == t ? void 0 : t.swiperCurrent,
        pic: null == t ? void 0 : t.pic,
      });
    },
    toPrivacy: function () {
      (0, o.navigateTo)(u.default.PAGE_MINE_PRIVACY, {});
    },
  },
});
